import time
import traceback
import random

from selenium.webdriver import ActionChains, Keys

from MyTools.myutils import TestUtils
import pdb
cookie_str = 'Admin-Expires-In=1440; sidebarStatus=0; Admin-Token=c3f64485-fd6e-4910-a82b-ce6b6d2b66ad; SECKEY_ABVK=xMue/s1kyC/V9dBuwcl0oCop1ISns13saPn8GIvuW9M=; BMAP_SECKEY=2EtMLrnl8qsLazv-pcjV9zqpT_5nk98636xO0gZtPJjHJgQ1BO-zZXTz_f1STdDZQNp4dC7WAIBJjaYE8OfOD5Ws3dN9axNzJQd7MmHo5zsyNunHT5FLJ8Z-1eCyoYXXXv3xgkpsdWYHu6AmDIxv6YzhYM-Vr8xp9dquT-nY9VL0EJBSoIknZp7E_6Dz9uwz; integrated-platform-Token=fa999fac-4b89-4495-aa43-33eea59e284d'
zs_cookie_str = 'Admin-Expires-In=43200; sidebarStatus=0; integrated-platform-Token=0411c203-59f4-459f-b089-5c8cc00f8d86; SECKEY_ABVK=fkjRI8QKhV3Cb9ifksaOTfacFFaZrIZVt1wxXlkOO+4%3D; BMAP_SECKEY=sKl97EAGng9tNrnsQJtDHFsbAY9vgYQiM8mh828IkmI8uarw9o07hDvOw9j9K4D0yvf-8_nPpKlC1VsnYmJGaSQNwLF75q04eQu-J3Fty7xENsMwhcupVe_lsHeTYLojv-6ceP928a_eJHxjR491KrTEa0gQK197T4a03M25i2RWo2zOiREZ9ITUYnOiTvfN'
# self.click_when_visible('')
sj_number = str(random.randint(1, 1000))

class MytestClass(TestUtils):
    # 新建普通商品
    def do_ysc_spgl_pt(self):

        self.open("http://10.0.0.75:811/index")
        time.sleep(3)
        try:
            actions = ActionChains(self.driver)
            self.cookie_adder(cookie_str)
            self.check_status(self)
            self.maximize_window()

            ######################## 新建商品 ########################
            self.open("http://10.0.0.75:811/applicate/goods")
            self.click_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.goods-table > div.goods-table-right > div:nth-child(1) > div:nth-child(1) > button')

            #商品名称
            time.sleep(1)
            self.send_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(1) > div > div > input', "云商城商品_软件_"+sj_number)
            #商品分类
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.DOWN).perform()
            actions.send_keys(Keys.ENTER).perform()

            #商品类型
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.ENTER).perform()
            actions.send_keys(Keys.DOWN).perform()
            actions.send_keys(Keys.ENTER).perform()

            # #单位
            self.sendkey_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(5) > div > div > div > input','enter')
            self.sendkey_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(5) > div > div > div > input','down')
            self.sendkey_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(5) > div > div > div > input','enter')
            #品牌
            self.send_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(6) > div > div > input',"商品品牌"+sj_number)
            #型号
            self.send_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(7) > div > div > input','商品型号'+sj_number)
            #产地
            self.send_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(8) > div > div > input','商品产地'+sj_number)
            #商品描述
            self.send_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(9) > div > div > textarea','商品描述'+sj_number)
            #商品属性
            self.send_keys('input[type="file"][accept=".doc,.docx,.xlsx,.xls,.jpg,.jpeg,.png,.gif,.pdf"].el-upload__input', 'C:/Users/Administrator.SC-201811252126/Pictures/jinbu.jpg')
            self.send_keys('input[type="file"][accept=".jpg,.png,.jpeg"].el-upload__input', 'C:/Users/Administrator.SC-201811252126/Pictures/jinbu.jpg')
            self.actions_tab(6)
            actions.send_keys("规格"+sj_number).perform()
            self.actions_tab(2)
            actions.send_keys(Keys.ENTER).perform()
            #self.send_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(5) > div > div > div > div.el-table__body-wrapper.is-scrolling-none > table > tbody > tr > td.el-table_6_column_57.is-left.el-table__cell > div > div > div > input','规格'+sj_number)
            #elf.click_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(5) > div > div > div > div.el-table__fixed-right > div.el-table__fixed-body-wrapper > table > tbody > tr > td.el-table_3_column_28.is-left.el-table__cell > div > button:nth-child(1)')
            #价格设置
            self.click_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(8) > div.functional-block-context.el-row > div > div > span')
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys("3.35").perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys("5.35").perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys("1.35").perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys("7.35").perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys("5.35").perform()

            #预警设置暂时不写

            #其他设置暂时不写

            #标签设置
            pdb.set_trace()  # 断点
            #self.click_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(15) > div > div > div > div > div.el-select.el-select--mini > div > span > span > i')
            actions.send_keys(Keys.DOWN).perform()
            actions.send_keys(Keys.ENTER).perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.ENTER).perform()

            print("所有功能点已完成，测试通过！")


        except Exception as e:
            #tb_str = traceback.format_exception(etype=type(e), value=e, tb=e.__traceback__)
            print("@@@@@@@@@@@@@@@@@@@@ 出现错误了先暂停一下，方便调试！@@@@@@@@@@@@@@@@@@@@@@@@")
            print(f"抱歉，出现错误：{str(e)}")
            pdb.set_trace()
            #print("".join(tb_str))  # 显示详细的错误追踪信息，包括在哪一行代码触发的错误
    # 新建组合商品
    def do_ysc_spgl_zh(self):

        self.open("http://10.0.0.75:811/index")
        time.sleep(3)
        try:
            actions = ActionChains(self.driver)
            self.cookie_adder(cookie_str)
            self.check_status(self)
            self.maximize_window()

            ######################## 新建商品 ########################
            self.open("http://10.0.0.75:811/applicate/goods")
            self.click_when_visible(
                '#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.goods-table > div.goods-table-right > div:nth-child(1) > div:nth-child(1) > button')

            # 商品名称
            time.sleep(1)
            self.send_when_visible(
                '#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(1) > div > div > input',
                "云商城组合产品" + sj_number)
            # 商品分类
            actions.send_keys(Keys.TAB).perform()
            self.actions_down(2)
            actions.send_keys(Keys.ENTER).perform()

            # 商品类型
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.ENTER).perform()
            actions.send_keys(Keys.DOWN).perform()
            actions.send_keys(Keys.ENTER).perform()

            # #单位
            self.sendkey_when_visible(
                '#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(5) > div > div > div > input',
                'enter')
            self.sendkey_when_visible(
                '#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(5) > div > div > div > input',
                'down')
            self.sendkey_when_visible(
                '#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(5) > div > div > div > input',
                'enter')


            # 型号
            self.send_when_visible(
                '#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(6) > div > div > input',
                '商品型号' + sj_number)

            # 商品描述
            self.send_when_visible(
                '#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(7) > div > div > textarea',
                '商品描述' + sj_number)

            self.send_keys('input[type="file"].el-upload__input', 'C:/Users/Administrator.SC-201811252126/Pictures/bdj.jpg')
            time.sleep(2)

            # 选择商品
            self.click_when_visible('#btn_commodity')
            self.send_keys(
                '#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div:nth-child(3) > div > div > div > section > div > div.goods-box > div.goods-top > form > div:nth-child(1) > div:nth-child(1) > div > div > input',
                '云商城商品')


            self.actions_tab(4)

            actions.send_keys(Keys.ENTER).perform()
            self.actions_tab(2)
            time.sleep(1)
            actions.send_keys(Keys.SPACE).perform()
            self.actions_tab(8)
            actions.send_keys(Keys.ENTER).perform()

            # actions.send_keys(Keys.TAB).perform()
            # actions.send_keys(Keys.TAB).perform()
            # actions.send_keys(Keys.TAB).perform()
            # actions.send_keys(Keys.SPACE).perform()
            # self.click_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div:nth-child(3) > div > div > div > section > div > div.goods-footer > div > button.el-button.el-button--primary.el-button--mini')

            # 价格设置
            self.actions_tab(2)
            actions.send_keys("135").perform()

            self.actions_tab(4)
            actions.send_keys("153").perform()

            self.actions_tab(4)
            actions.send_keys("315").perform()

            self.actions_tab(4)
            actions.send_keys("513").perform()
            self.actions_tab(23)
            actions.send_keys(Keys.ENTER).perform()

            # 预警设置暂时不写

            # 其他设置暂时不写

            # 特殊设置
            #self.actions_tab(9)
            #actions.send_keys(Keys.ENTER).perform()
            #self.click_when_visible('body > div.el-message-box__wrapper > div > div.el-message-box__btns > button.el-button.el-button--default.el-button--small.el-button--primary')

            self.actions_tab(9)
            actions.send_keys("135").perform()
            self.actions_tab(2)
            actions.send_keys('1').perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.ENTER).perform()
            self.actions_down(3)
            actions.send_keys(Keys.ENTER).perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys('2').perform()
            self.actions_tab(2)
            actions.send_keys('35').perform()
            # actions.send_keys(Keys.TAB).perform()
            # actions.send_keys(Keys.ENTER).perform()
            # actions.send_keys(Keys.TAB).perform()
            # actions.send_keys('3').perform()
            # self.actions_tab(2)
            # actions.send_keys("4").perform()
            # self.actions_tab(2)
            # actions.send_keys('55').perform()
            self.actions_tab(5)
            pdb.set_trace()  # 断点

            actions.send_keys(Keys.ENTER).perform()

            actions.send_keys(Keys.TAB).perform()
            time.sleep(1)

            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.ENTER).perform()

            print("所有功能点已完成，测试通过！")


        except Exception as e:
            # tb_str = traceback.format_exception(etype=type(e), value=e, tb=e.__traceback__)
            print(f"抱歉，出现错误：{str(e)}")
            # print("".join(tb_str))  # 显示详细的错误追踪信息，包括在哪一行代码触发的错误

    def do_ysc_cpgl(self):

        self.open("http://10.0.0.75:4321")
        time.sleep(3)
        try:
            self.cookie_adder(cookie_str)
            self.check_status(self)
            self.maximize_window()
            self.send_when_visible('#app-page > div > div > div > form > div:nth-child(3) > div > div > div > input','qxf123456')
            time.sleep(1)
            self.click_when_visible('#app-page > div > div > div > button')

            ######################## 云商城权限管理 ########################
            self.open("http://10.0.0.75:4321/element/tailorism#/tailorism")

            self.click_when_visible('#app > div > div > div.z1-table-layout-tool > div > div > button')

            self.send_when_visible('#app-page > div > div.layout-container > div.layout-content > div > micro-app > micro-app-body > div.el-drawer__wrapper > div > div > section > div.drawer-container > form > div:nth-child(1) > div.toggle-box-content > div:nth-child(1) > div.el-col.el-col-12 > div > div > div > input','产品'+sj_number)

            self.actions_tab(1)
            self.actions_enter(1)
            self.actions_down(1)
            self.actions_right(2)
            self.actions_enter(1)

            self.click_when_visible('#app-page > div > div.layout-container > div.layout-content > div > micro-app > micro-app-body > div.el-drawer__wrapper > div > div > section > div.drawer-container > form > div:nth-child(1) > div.toggle-box-content > div:nth-child(1) > div:nth-child(3) > div > div > span > div > div:nth-child(2) > label > div')

            self.send_when_visible('#app-page > div > div.layout-container > div.layout-content > div > micro-app > micro-app-body > div.el-drawer__wrapper > div > div > section > div.drawer-container > form > div:nth-child(1) > div.toggle-box-content > div:nth-child(2) > div > div > div > div > textarea','从“托运”到“承运”、从“转货点”到“卸货点”、甚至从“买方”到“卖方”...我们正在研发从物流生态体系一端到另一端均能满足客户需求的解决方案。利用超好运网络货运平台司机、车辆、货源等数据资源优势，通过一站式平台对接数字物流中不同行业的多边供给方，整合现代化的信息技术进行资源共享，沉淀真实有效的交易数据，建立有序、便捷、长效的数字物流生态系统。')

            self.actions_tab(2)
            self.actions_down(1)
            self.actions_enter(1)
            self.actions_tab(1)
            self.actions_down(7)
            self.actions_enter(1)

            self.actions_tab(1)
            self.actions_down(2)
            self.actions_enter(1)

            self.actions_tab(1)
            self.actions_send('3')

            self.click_when_visible('#pane-1 > div > div:nth-child(1) > div:nth-child(1) > div > label > div > button > div > span')
            self.actions_tab(13)
            self.actions_send('单独计价718')
            #self.send_when_visible('#app-page > div > div.layout-container > div.layout-content > div > micro-app > micro-app-body > div:nth-child(11) > div > div > section > div.drawer-container > div > div.z1-table-layout-search > div > div.z1-table-search-fields.z1-table-search_no_fields > div > div:nth-child(1) > div > div.z1-table-search-item__content > div > input','单独计价718')
            self.actions_tab(3)
            time.sleep(2)
            self.actions_enter(1)
            time.sleep(2)
            self.actions_tab(1)
            self.actions_space(1)
            self.actions_tab(3)
            self.actions_enter(1)
            self.actions_tab(1)
            self.actions_send('大道成产品:'+sj_number)

            #新版本
            # self.click_when_visible('#app-page > div > div.layout-container > div.layout-content > div > micro-app > micro-app-body > div:nth-child(14) > div > div > section > div.drawer-container > form > div.toggle-box.tailorism-version-index > div.toggle-box-content > div.mt-sm.z1-space.z1-space-align-center > div:nth-child(1) > button')#app-page > div > div.layout-container > div.layout-content > div > micro-app > micro-app-body > div:nth-child(6) > div > div > section > div.drawer-container > form > div.toggle-box.tailorism-version-index > div.toggle-box-content > div.mt-sm.z1-space.z1-space-align-center > div:nth-child(1) > button
            # self.actions_tab(1)
            # self.actions_enter(1)
            # self.send_when_visible('#app-page > div > div.layout-container > div.layout-content > div > micro-app > micro-app-body > div:nth-child(6) > div > div > section > div.drawer-container > div > div.z1-table-layout-search > div > div.z1-table-search-fields.z1-table-search_no_fields > div > div:nth-child(1) > div > div.z1-table-search-item__content > div > input','云商城组合产品')
            # self.actions_tab(3)
            # self.actions_enter(1)
            # time.sleep(2)
            # self.actions_tab(1)
            # self.actions_space(1)
            # self.click_when_visible('#app-page > div > div.layout-container > div.layout-content > div > micro-app > micro-app-body > div:nth-child(6) > div > div > section > div.drawer-footer > button.z1-button.z1-button-primary.z1-button-normal')

            #版本优势点
            self.actions_tab(12)
            self.actions_enter(4)
            self.actions_tab(1)
            self.actions_send('“五统合一”，业务真实可靠获福清市首张网络货运道路运输许可证')
            self.actions_tab(1)
            self.actions_send('操作与业务流程简单，极易上手，出票及时，按需月结可多次出票')
            self.actions_tab(1)
            self.actions_send('保障资金管理安全合理；运费一键结，打款快捷')
            self.actions_tab(1)
            self.actions_send('全国线下团队驻点一对一服务客户，全时段多方位响应，提供资深专家咨询服务')
            self.actions_tab(1)
            self.actions_send('实时动态信息，油气ETC等多元服务；全场景信息化产业供应链服务')

            #版本介绍
            self.actions_tab(1)
            self.actions_send('云商城版本：'+sj_number)
            self.actions_tab(1)
            self.actions_send('为车队提供运输过程管控服务，实现管理透明化、信息化')
            self.actions_tab(1)
            self.actions_enter(1)
            self.actions_tab(1)
            self.actions_send('云商城版本V2：'+sj_number)
            self.actions_tab(1)
            self.actions_send('联动集运各环节数据，多业务数智化处理，提供智能物流服务')

            #图片
            self.send_when_visible('input[type=file].el-upload__input','C:/Users/Administrator.SC-201811252126/Pictures/jinbu.jpg')

            #详情信息
            self.actions_tab(4)
            self.actions_down(1)
            self.actions_enter(1)
            self.click_when_visible('#app-page > div > div.layout-container > div.layout-content > div > micro-app > micro-app-body > div:nth-child(6) > div > div > section > div.drawer-container > form > div:nth-child(3) > div.toggle-box-content > form > div.mt-sm.z1-space.z1-space-align-center > div > div > div > div:nth-child(2) > div')
            #这边要上传图片
            self.click_when_visible('#app-page > div > div.layout-container > div.layout-content > div > micro-app > micro-app-body > div:nth-child(6) > div > div > section > div.drawer-container > form > div:nth-child(3) > div.toggle-box-content > form > div.mt-sm.z1-space.z1-space-align-center > div > div > div > div:nth-child(3) > div')
            self.click_when_visible('#app-page > div > div.layout-container > div.layout-content > div > micro-app > micro-app-body > div:nth-child(6) > div > div > section > div.drawer-container > form > div:nth-child(3) > div.toggle-box-content > form > div:nth-child(2) > div:nth-child(3) > div:nth-child(2) > div > div.el-col.el-col-6 > div > div > div:nth-child(2) > img')
            self.click_when_visible('#app-page > div > div.layout-container > div.layout-content > div > micro-app > micro-app-body > div:nth-child(6) > div > div > section > div.drawer-container > form > div:nth-child(3) > div.toggle-box-content > form > div:nth-child(2) > div:nth-child(3) > div:nth-child(2) > div > div.el-col.el-col-6 > div > div > div:nth-child(3) > img')
            self.click_when_visible('#app-page > div > div.layout-container > div.layout-content > div > micro-app > micro-app-body > div:nth-child(6) > div > div > section > div.drawer-container > form > div:nth-child(3) > div.toggle-box-content > form > div:nth-child(2) > div:nth-child(3) > div:nth-child(2) > div > div.el-col.el-col-6 > div > div > div:nth-child(4) > img')
            self.send_when_visible('#app-page > div > div.layout-container > div.layout-content > div > micro-app > micro-app-body > div:nth-child(6) > div > div > section > div.drawer-container > form > div:nth-child(3) > div.toggle-box-content > form > div:nth-child(2) > div:nth-child(3) > div:nth-child(2) > div > div.el-col.el-col-18 > div:nth-child(2) > div.editor.ql-container.ql-snow > div.ql-editor.ql-blank','数字采销整体解决方案以实现大宗货品全流程数字化为抓手，旨在提高采销业务效率、优化供应链、降低成本，实现更高效、精准的大宗货品交易管理。数字采销整体解决方案以数字采销管理系统为核心，它提供标准版和升级版两个版本，并支持根据客户需求提供个性化定制服务。')

            self.click_when_visible('#app-page > div > div.layout-container > div.layout-content > div > micro-app > micro-app-body > div:nth-child(6) > div > div > section > div.drawer-container > form > div:nth-child(3) > div.toggle-box-content > form > div.mt-sm.z1-space.z1-space-align-center > div > div > div > div:nth-child(4) > div')
            self.send_when_visible('#app-page > div > div.layout-container > div.layout-content > div > micro-app > micro-app-body > div:nth-child(6) > div > div > section > div.drawer-container > form > div:nth-child(3) > div.toggle-box-content > form > div:nth-child(2) > div:nth-child(4) > div > div:nth-child(2) > div > div > div:nth-child(2) > div > div:nth-child(3) > div > div > textarea','大宗商品交易管理')
            self.send_when_visible('#app-page > div > div.layout-container > div.layout-content > div > micro-app > micro-app-body > div:nth-child(6) > div > div > section > div.drawer-container > form > div:nth-child(3) > div.toggle-box-content > form > div:nth-child(2) > div:nth-child(4) > div > div:nth-child(2) > div > div > div:nth-child(2) > div > div:nth-child(4) > div > div > textarea','支持多场景开单，包括销售协议、库存开单，满足不同经营模式。通过采智能购策略和采购询价，提高库存周转，降低运营成本。')


            pdb.set_trace()#断点
        except Exception as e:
            tb_str = traceback.format_exception(etype=type(e), value=e, tb=e.__traceback__)
            print(f"抱歉，出现错误：{str(e)}")
            print("".join(tb_str))  # 显示详细的错误追踪信息，包括在哪一行代码触发的错误

    def do_ysc_spgl_rj_zs(self):

        self.open("http://z1xt.cn/")
        time.sleep(3)
        try:
            actions = ActionChains(self.driver)
            self.cookie_adder(zs_cookie_str)
            #self.check_status(self)
            self.maximize_window()

            ######################## 新建商品 ########################
            self.open("http://z1xt.cn/applicate/goods")
            self.click_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.goods-table > div.goods-table-right > div:nth-child(1) > div:nth-child(1) > button')

            #商品名称
            time.sleep(1)
            self.send_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(1) > div > div > input', "云商城商品_软件_"+sj_number)
            #商品分类
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.DOWN).perform()
            actions.send_keys(Keys.ENTER).perform()

            #商品类型
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.ENTER).perform()
            actions.send_keys(Keys.DOWN).perform()
            actions.send_keys(Keys.ENTER).perform()

            # #单位
            self.sendkey_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(5) > div > div > div > input','enter')
            self.sendkey_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(5) > div > div > div > input','down')
            self.sendkey_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(5) > div > div > div > input','enter')
            #品牌
            self.send_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(6) > div > div > input',"商品品牌"+sj_number)
            #型号
            self.send_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(7) > div > div > input','商品型号'+sj_number)
            #产地
            self.send_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(8) > div > div > input','商品产地'+sj_number)
            #商品描述
            self.send_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(9) > div > div > textarea','商品描述'+sj_number)
            #商品属性
            self.send_keys('input[type="file"][accept=".doc,.docx,.xlsx,.xls,.jpg,.jpeg,.png,.gif,.pdf"].el-upload__input', 'C:/Users/Administrator.SC-201811252126/Pictures/jinbu.jpg')
            self.send_keys('input[type="file"][accept=".jpg,.png,.jpeg"].el-upload__input', 'C:/Users/Administrator.SC-201811252126/Pictures/jinbu.jpg')
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys("规格"+sj_number).perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.ENTER).perform()
            #self.send_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(5) > div > div > div > div.el-table__body-wrapper.is-scrolling-none > table > tbody > tr > td.el-table_6_column_57.is-left.el-table__cell > div > div > div > input','规格'+sj_number)
            #elf.click_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(5) > div > div > div > div.el-table__fixed-right > div.el-table__fixed-body-wrapper > table > tbody > tr > td.el-table_3_column_28.is-left.el-table__cell > div > button:nth-child(1)')
            #价格设置
            self.click_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(8) > div.functional-block-context.el-row > div > div > span')
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys("3.35").perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys("5.35").perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys("1.35").perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys("7.35").perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys("5.35").perform()

            #预警设置暂时不写

            #其他设置暂时不写

            #标签设置
            pdb.set_trace()  # 断点
            self.click_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(15) > div > div > div > div > div.el-select.el-select--mini > div > span > span > i')
            actions.send_keys(Keys.DOWN).perform()
            actions.send_keys(Keys.ENTER).perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.ENTER).perform()

            print("所有功能点已完成，测试通过！")


        except Exception as e:
            #tb_str = traceback.format_exception(etype=type(e), value=e, tb=e.__traceback__)
            print(f"抱歉，出现错误：{str(e)}")
            #print("".join(tb_str))  # 显示详细的错误追踪信息，包括在哪一行代码触发的错误

    def do_ysc_spgl_rj_zh_zs(self):

        self.open("http://z1xt.cn/")
        time.sleep(3)
        try:
            actions = ActionChains(self.driver)
            self.cookie_adder(zs_cookie_str)
            #self.check_status(self)
            self.maximize_window()

            ######################## 新建商品 ########################
            self.open("http://z1xt.cn/applicate/goods")
            self.click_when_visible(
                '#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.goods-table > div.goods-table-right > div:nth-child(1) > div:nth-child(1) > button')

            # 商品名称
            time.sleep(1)
            self.send_when_visible(
                '#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(1) > div > div > input',
                "云商城组合" + sj_number)
            # 商品分类
            actions.send_keys(Keys.TAB).perform()
            self.actions_down(2)
            actions.send_keys(Keys.ENTER).perform()

            # 商品类型
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.ENTER).perform()
            actions.send_keys(Keys.DOWN).perform()
            actions.send_keys(Keys.ENTER).perform()

            # #单位
            self.sendkey_when_visible(
                '#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(5) > div > div > div > input',
                'enter')
            self.sendkey_when_visible(
                '#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(5) > div > div > div > input',
                'down')
            self.sendkey_when_visible(
                '#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(5) > div > div > div > input',
                'enter')


            # 型号
            self.send_when_visible(
                '#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(6) > div > div > input',
                '商品型号' + sj_number)

            # 商品描述
            self.send_when_visible(
                '#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div.add-sale-order-body > form > div.add-sale-order-body-main > div > div > div > div:nth-child(2) > div:nth-child(7) > div > div > textarea',
                '商品描述' + sj_number)

            self.send_keys('input[type="file"].el-upload__input', 'C:/Users/Administrator.SC-201811252126/Pictures/bdj.jpg')
            time.sleep(2)

            # 选择商品
            self.click_when_visible('#btn_commodity')
            self.send_keys(
                '#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div:nth-child(3) > div > div > div > section > div > div.goods-box > div.goods-top > form > div:nth-child(1) > div:nth-child(1) > div > div > input',
                '云商城商品')


            self.actions_tab(4)

            actions.send_keys(Keys.ENTER).perform()
            self.actions_tab(2)
            time.sleep(1)
            actions.send_keys(Keys.SPACE).perform()
            self.actions_tab(8)
            actions.send_keys(Keys.ENTER).perform()

            # actions.send_keys(Keys.TAB).perform()
            # actions.send_keys(Keys.TAB).perform()
            # actions.send_keys(Keys.TAB).perform()
            # actions.send_keys(Keys.SPACE).perform()
            # self.click_when_visible('#app > div > div.app-wrapper__container.ly-flex-1 > div.main-container.hasTagsView > section > div > div > div:nth-child(3) > div > div > div > section > div > div.goods-footer > div > button.el-button.el-button--primary.el-button--mini')

            # 价格设置
            self.actions_tab(2)
            actions.send_keys("135").perform()

            self.actions_tab(4)
            actions.send_keys("153").perform()

            self.actions_tab(4)
            actions.send_keys("315").perform()

            self.actions_tab(4)
            actions.send_keys("513").perform()
            self.actions_tab(23)
            actions.send_keys(Keys.ENTER).perform()

            # 预警设置暂时不写

            # 其他设置暂时不写

            # 特殊设置
            #self.actions_tab(9)
            #actions.send_keys(Keys.ENTER).perform()
            #self.click_when_visible('body > div.el-message-box__wrapper > div > div.el-message-box__btns > button.el-button.el-button--default.el-button--small.el-button--primary')

            self.actions_tab(9)
            actions.send_keys("135").perform()
            self.actions_tab(2)
            actions.send_keys('1').perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.ENTER).perform()
            self.actions_down(3)
            actions.send_keys(Keys.ENTER).perform()
            actions.send_keys(Keys.TAB).perform()
            actions.send_keys('2').perform()
            self.actions_tab(2)
            actions.send_keys('35').perform()
            # actions.send_keys(Keys.TAB).perform()
            # actions.send_keys(Keys.ENTER).perform()
            # actions.send_keys(Keys.TAB).perform()
            # actions.send_keys('3').perform()
            # self.actions_tab(2)
            # actions.send_keys("4").perform()
            # self.actions_tab(2)
            # actions.send_keys('55').perform()
            self.actions_tab(5)
            pdb.set_trace()  # 断点

            actions.send_keys(Keys.ENTER).perform()

            actions.send_keys(Keys.TAB).perform()
            time.sleep(1)

            actions.send_keys(Keys.TAB).perform()
            actions.send_keys(Keys.ENTER).perform()

            print("所有功能点已完成，测试通过！")


        except Exception as e:
            # tb_str = traceback.format_exception(etype=type(e), value=e, tb=e.__traceback__)
            print(f"抱歉，出现错误：{str(e)}")
            # print("".join(tb_str))  # 显示详细的错误追踪信息，包括在哪一行代码触发的错误

    def test_ysc(self):
        #软件
        #self.do_ysc_spgl_pt()
        self.do_ysc_spgl_zh()
        #self.do_ysc_spgl_rj_zs()
        #self.do_ysc_spgl_rj_zh_zs()
        #self.do_ysc_cpgl()